package cn.easyutil.project.demo.controller;

import cn.easyutil.project.base.exception.CommonException;
import cn.easyutil.project.base.service.BaseService;
import cn.easyutil.project.base.sqlExecuter.SQLExecuter;
import cn.easyutil.project.base.util.JsonUtil;
import cn.easyutil.project.demo.bean.UserBean;
import cn.easyutil.project.demo.context.BizError;
import cn.easyutil.project.web.util.RequestPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class TestController {

    @Autowired
    private BaseService baseService;


    @GetMapping("10001")
    public List<UserBean> get(UserBean bean){
        RequestPool.setSmsCode("18606166467","1234");
        RequestPool.setCacheAttribute("name","小明");
        SQLExecuter.build(new UserBean());
        List<UserBean> select = baseService.select(new UserBean());
        return select;
    }

    @GetMapping("10002")
    public void update(UserBean bean){
        System.out.println(RequestPool.getSmsCode("18606166467"));
        System.out.println(RequestPool.getCacheAttribute("name"));
    }

    @GetMapping("10003")
    public List<UserBean> list(){
        List<UserBean> list = new ArrayList<>();
        list.add(new UserBean("186********","123456","小明"));
        list.add(new UserBean("166********","123456","小花"));
        list.add(new UserBean("176********","123456","小宝"));
        return list;
    }

}
